﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;

namespace XingFuStudio.Pioneer.Container {
    /// <summary>
    /// 配置管理类
    /// </summary>
    public class ConfigManager {
        /// <summary>
        /// 获取插件配置
        /// </summary>
        /// <param name="xmlConfigPath">插件配置Xml文件路径</param>
        /// <returns></returns>
        public ConfigSection GetConfig(string xmlConfigPath) {
            //初始化配置对象
            ConfigSection info = new ConfigSection();

            //获取Xml
            XElement xmlConfig = XElement.Load(xmlConfigPath);
            
            //赋值属性
            info.AssemblyName = xmlConfig.Element("AssemblyName").Value;
            info.PluginId = Convert.ToInt32(xmlConfig.Element("AppCode").Value);
            info.PluginName = xmlConfig.Element("AppName").Value;
            info.PluginText = xmlConfig.Element("AppText").Value;
            info.TypeName = xmlConfig.Element("TypeName").Value;

            //返回配置
            return info;
        }
    }
}
